package com.vic.designpattern.patterns.c_behavioral.state.demo1;

/**
 * @author victor
 */
public class BotContext {

    private State state = new DisconnectedState();

    public String chat(String input) {
        // 收到hello 切换到在线状态
        if("hello".equalsIgnoreCase(input)) {
            state = new ConnectedState();
            return state.init();
        } else if("bye".equalsIgnoreCase(input)) {
            // 收到bye 切换到离线状态
            state = new DisconnectedState();
            return state.init();
        }
        return state.reply(input);
    }

}
